package Runde5;

public abstract class Person implements Comparable<Person>{
	
	/**
	 * @precondition name must not be empty, name != null
	 * @postcondition creates a new person with given name
	 */
	private String name;
	public Person (String name) {
		this.name = name;
	}
	
	/**
	 * @postcondition "Compares two strings lexicographically. The comparison is based on the Unicode value of each character in the strings.
	 *  The character sequence represented by this String object is compared lexicographically to the character sequence represented by the
	 *  argument string. The result is a negative integer if this String object lexicographically precedes the argument string. The result is
	 *  a positive integer if this String object lexicographically follows the argument string. The result is zero if the strings are equal;
	 *  compareTo returns 0 exactly when the equals(Object) method would return true."
	 */
	public int compareTo(Person that) {
		return this.name.toLowerCase().compareTo(that.name.toLowerCase());
	}
	
	/**
	 * @postcondition delivers a readable form of this instance of person
	 */
	public String toString() {
		return name;
	}
}
